
import java.io.InputStream;
import javax.microedition.media.Manager;
import javax.microedition.media.MediaException;
import javax.microedition.media.Player;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author SK8ERBOI
 */
public class Audio {
    private String mAudioRSC;
    Player player;

    public Audio(String mAudioRSC) {
        this.mAudioRSC = mAudioRSC;
    }

    public void playFromResource() {
        try {
            InputStream in = getClass().getResourceAsStream("/sounds/" + this.mAudioRSC);
            player = Manager.createPlayer(in, "audio/midi");
            player.start();
        } catch (Exception e) {
            return;
        }


    }

    public void stop() {
        if (player!=null) {
            try {
                player.stop();
            } catch (MediaException ex) {
                ex.printStackTrace();
            }
        }
    }
    
    public void Start()
    {
        if (player.getState() == Player.STARTED) {
            try {
                player.stop();
            } catch (MediaException ex) {
                ex.printStackTrace();
            }
        }
    }
}